package org.example.tika;/*
 * title:
 * author:
 * date:
 * description:
 * */

import org.apache.tika.parser.txt.UniversalEncodingDetector;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.tika.metadata.Metadata;

public class Tika {
    public static void main(String[] args) throws IOException {
        UniversalEncodingDetector universalEncodingDetector = new UniversalEncodingDetector();
        BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream("C:\\Users\\11924\\Desktop\\test.txt"));
        Metadata metadata = new Metadata();
        metadata.set(Metadata.CONTENT_TYPE, null);
        Charset detect = universalEncodingDetector.detect(inputStream, metadata);
        System.out.println(detect);
    }
}
